package com.atguigu.springcloud.service.serviceImpl;

import com.atguigu.springcloud.dao.StorageDao;
import com.atguigu.springcloud.service.StorageService;
import io.seata.spring.annotation.GlobalTransactional;
import lombok.extern.slf4j.Slf4j;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author :hucaiyuan
 * @date :2022/02/26   14:51
 * @description :
 */
@Slf4j
@Service
public class StorageServiceImpl implements StorageService {
    @Autowired
    private StorageDao storageDao;
    @Override
    @GlobalTransactional(name="fsp-storage",rollbackFor = Exception.class)
    public void decrease(Long productId, Integer count) {
          log.info("----->开始扣减库存!");
          storageDao.decrease(productId,count);
          log.info("--->扣减库存成功!");
    }
}
